﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Microsoft.Forums.OfflineStore;

namespace Microsoft.Forums.ForumsClient
{
    /// <summary>
    ///  Class to convert Forum IsPrivate property to System.Windows.Visibility.
    /// </summary>
    public class IsPublicForumVisible : IValueConverter
    {
        /// <summary>
        /// If the IsPrivate property is true, the public forum icon is not visible 
        /// </summary>
        /// <param name="value">boolean representing the state of the IsPrivate property</param>
        /// <param name="targetType">Should be System.Windows.Visibility</param>
        /// <param name="parameter">not used</param>
        /// <param name="culture">not used</param>
        /// <returns>System.Windows.Visibility.Hidden if value is true. Otherwise, System.Windows.Visibility.Visible or </returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                throw new ArgumentNullException("value");
            if (targetType != typeof(System.Windows.Visibility))
                throw new InvalidCastException("IsPublicForumVisible: unexpected type of " + targetType.ToString());
            bool isForumPrivate = (bool)value;
            return (isForumPrivate ? System.Windows.Visibility.Hidden : System.Windows.Visibility.Visible);
        }

        /// <summary>
        /// Method Not Implemented. Throws NotSupportedException
        /// </summary>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException("ConvertBack is not supported.");
        }
    }
}
